﻿using System;
using System.Collections.Generic;

using RexToy.DesignPattern;
using RexToy.UI.WinForm.Controls;

namespace RexToy.UI.WinForm
{
    public class CommandBindRegistry : Singleton<CommandBindRegistry>
    {
        private List<IBindCommand> _list;

        private CommandBindRegistry()
        {
            _list = new List<IBindCommand>();
        }

        public void RequeryCanExecute()
        {
            foreach (IBindCommand bind in _list)
            {
                bind.QueryCanExecute();
            }
        }

        public void PutItem(IBindCommand bind)
        {
            if (!_list.Contains(bind))
                _list.Add(bind);
        }

        public void RemoveItem(IBindCommand bind)
        {
            if (_list.Contains(bind))
                _list.Remove(bind);
        }
    }
}
